<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>测试</title>
    <link href="css/qt/goexam.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="script/jquery/jquery-1.5.1.min.js">
        </script>
    <script type="text/javascript">
        <c:if test="${!empty queslist}">
          <c:if test="${!empty queslist.xzlist}">
          var xzids=new Array(<c:forEach items="${queslist.xzlist }" var="ques" varStatus="ss">${ques.id},</c:forEach>0);
	     </c:if>
         <c:if test="${!empty queslist.tklist}">
         var tkids=new Array(<c:forEach items="${queslist.tklist }" var="ques" varStatus="ss">${ques.id},</c:forEach>0);
	     </c:if>
	     <c:if test="${!empty queslist.pdlist}">
         var pdids=new Array(<c:forEach items="${queslist.pdlist }" var="ques" varStatus="ss">${ques.id},</c:forEach>0);
	     </c:if>
	     <c:if test="${!empty queslist.jdlist}">
         var jdids=new Array(<c:forEach items="${queslist.jdlist }" var="ques" varStatus="ss">${ques.id},</c:forEach>0);
	     </c:if>
        </c:if>
	    $(function() {
	        if(!window.ActiveXObject){
		      $("#footht").css("height","20px");
	        }
	        initZYbg();
	   	     $(window).resize(function() {
			    initZYbg();
			   });
	    });
function initZYbg(){ 
	//alert($(document).width());
       if(document.body.clientWidth<957){
	        $("#mainleft").width(0);
	        $("#mainright").width(0);
	        $("#mainleft").css("display","none");
		    $("#mainright").css("display","none");
        }else{
	       if(!window.ActiveXObject){
		        var wid=($(document).width()-953)/2;
		        $("#mainleft").width(wid);
		        $("#mainright").width(wid);
		        $("#mainleft").css("display","block");
		        $("#mainright").css("display","block");
		    }else{
		        var wid=($(document).width()-974)/2;
		        if(wid>0){
		        	$("#mainleft").width(wid);
			        $("#mainright").width(wid);
			        $("#mainleft").css("display","block");
			        $("#mainright").css("display","block");
		        }
		    }
        }
}
	    
	    function JiaoJuan(){
		    var xzans="",tkans="",pdans="",jdans="";
	    	var temp="";
               for(var i=0;i<xzids.length-1;i++){
            	   $("input[name='"+xzids[i]+"']").each(function(){
                      if($(this).attr("checked"))
                    	temp=temp+$(this).val()+"|";
           	    	});
          	    	if(temp.length>0){
          	    		xzans=xzans+xzids[i]+":"+temp.substring(0,temp.length-1)+"#";
          	    		temp="";
          	    	} 
               }
               for(var i=0;i<tkids.length-1;i++){
            	   $("input[name='"+tkids[i]+"']").each(function(){
                      if($(this).val().length>0){
                    	temp=temp+$(this).val()+"|";
                      }else{
                    	  temp=temp+" |";
                          }
           	    	});
          	    	if(temp.length>0){
          	    		tkans=tkans+tkids[i]+":"+temp.substring(0,temp.length-1)+"#";
          	    		temp="";
          	    	} 
               }
               for(var i=0;i<pdids.length-1;i++){
            	   $("input[name='"+pdids[i]+"']").each(function(){
                      if($(this).attr("checked"))
                    	temp=temp+$(this).val()+"|";
           	    	});
          	    	if(temp.length>0){
          	    		pdans=pdans+pdids[i]+":"+temp.substring(0,temp.length-1)+"#";
          	    		temp="";
          	    	} 
               }
               for(var i=0;i<jdids.length-1;i++){
            	   temp=$("#jd_"+jdids[i]).val();
          	    	if(temp.length>0){
          	    		jdans=jdans+jdids[i]+":"+temp+"#";
          	    		temp="";
          	    	}
               }
               if(xzans.length>0){
            	  xzans=xzans.substring(0,xzans.length-1);
               }
              if(tkans.length>0){
            	  tkans=tkans.substring(0,tkans.length-1);
               }
               if(pdans.length>0){
            	  pdans=pdans.substring(0,pdans.length-1);
               }
               if(jdans.length>0){
             	  jdans=jdans.substring(0,jdans.length-1);
                }
               $("#xzds").attr("value",xzans);
               $("#tkds").attr("value",tkans);
               $("#pdds").attr("value",pdans);  
               $("#jdds").attr("value",jdans);  
               $("#jiaojuansum").submit();
	    }
    </script>
    <SCRIPT LANGUAGE="JavaScript">   
		<!--   
		var maxtime = ${exam.len}*60-1;//60*30 //一个小时，按秒计算，自己调整!   
		function CountDown(){   
		if(maxtime>=0){   
			minutes = Math.floor(maxtime/60);   
			seconds = Math.floor(maxtime%60);   
			msg = minutes+":"+seconds;   
			document.all["timer"].innerHTML=msg;   
			--maxtime;   
		}else{   
			clearInterval(timer);   
			JiaoJuan();
			//alert("时间到，考试结束!"); 
			}   
		}   
		 <c:if test="${!empty queslist}">
		  timer = setInterval("CountDown()",1000);   
	     </c:if>
		
		//-->   
</SCRIPT>   
  </head>
  
  <body>
    <div id="mainleft"><img src="img/qt/mainleft.jpg" style="width:100%;height:100%;"/></div>
     <div id="main">
      <div id="top">
            <jsp:include page="title.jsp" flush="true">
             <jsp:param name="jspName" value="mykh" />
           </jsp:include>
           <div class="clear"></div>
       </div>
       <div id="tgTXT">
           <div id="tiao" style=""></div>
           <div id="mainbg">
	           <div style="height:10px;"> </div>
	           <div id="nowlist">
	              <div style="font-weight: bolder;margin-top:10px;margin:0 auto;">${exam.name}</div>
	              <div id="timeleng" style="width:100x;font-size:12px;float:left;margin:10px 0 0 430px;">[&nbsp;${exam.len}分钟&nbsp;]</div>
	              <div id="timer" style="width:100px;font-size:12px;margin:10px 0 0 300px;float:left;font-weight: bolder;color:#FF9B35">${exam.len}:00</div>
	           </div>
	           <div style="height:20px;clear:both;"> </div>
	           <c:if test="${!empty queslist}">
	              <table id="titable" cellpadding="0" cellspacing="0">
				    <tr><td style="height:35px;" colspan="2">一、选择题（10*2分）</td></tr>
				     <c:if test="${!empty queslist.xzlist}">
				       <c:forEach items="${queslist.xzlist }" var="ques" varStatus="ss">
				        <tr><td colspan='2'>
				             <span class="problems">${ss.count}.&nbsp;${ques.problem }</span>&nbsp;
				            </td>
				        </tr>
				          <c:if test="${fn:contains(ques.ans, '|')}">
				            <tr><td class="xuanxiang" colspan='2'><input type='checkbox' name='${ques.id}' value="1">&nbsp;A ${ques.op1 }</td></tr>
				            <tr><td class="xuanxiang" colspan='2'><input type='checkbox' name='${ques.id}' value="2">&nbsp;B ${ques.op2 }</td></tr>
				            <tr><td class="xuanxiang" colspan='2'><input type='checkbox' name='${ques.id}' value="3">&nbsp;C ${ques.op3 }</td></tr>
					          <c:if test="${fn:length(ques.op4)>0}">
					            <tr><td class="xuanxiang" colspan='2'><input type='checkbox' name='${ques.id}' value="4">&nbsp;D ${ques.op4 }</td></tr>
					          </c:if>
				          </c:if>
				          <c:if test="${! fn:contains(ques.ans, '|')}">
				            <tr><td class="xuanxiang" colspan='2'><input type='radio' name='${ques.id}' value="1">&nbsp;A ${ques.op1 }</td></tr>
				            <tr><td class="xuanxiang" colspan='2'><input type='radio' name='${ques.id}' value="2 ">&nbsp;B ${ques.op2 }</td></tr>
				            <tr><td class="xuanxiang" colspan='2'><input type='radio' name='${ques.id}' value="3">&nbsp;C ${ques.op3 }</td></tr>
				            <c:if test="${fn:length(ques.op4)>0}">
					            <tr><td class="xuanxiang" colspan='2'><input type='radio' name='${ques.id}' value="4">&nbsp;D ${ques.op4 }</td></tr>
					        </c:if>
				          </c:if>
					   </c:forEach>
				     </c:if>
				      <tr><td colspan="2"></td></tr>
				    <tr><td style="height:25px;" colspan="2">二、填空题（10*2分）</td></tr>
				    <c:if test="${!empty queslist.tklist}">
				       <c:forEach items="${queslist.tklist }" var="ques" varStatus="ss">
				        <tr>
				          <td colspan='2'>
				           <span class="problems">${ss.count}.&nbsp;${ques.problem }</span>&nbsp;
				          </td>
				        </tr>
				          <c:if test="${fn:contains(ques.ans, '|')}">
				          <tr><td class="tiankong">答案：</td><td> 
				            <c:forEach items="${fn:split(ques.ans, '|')}">
				              <input class='tkdaan' name="${ques.id }"  maxlength='100'/>
				            </c:forEach>
				           </td></tr>
				          </c:if>
				          <c:if test="${! fn:contains(ques.ans, '|')}">
				            <tr><td class="tiankong">答案：</td><td><input class='tkdaan' name="${ques.id }" maxlength='100'/></td></tr>
				          </c:if>
					   </c:forEach>
				     </c:if>
				      <tr><td colspan="2"></td></tr>
				    <tr><td style="height:25px;" colspan="2">三、判断题（10*2分）</td></tr>
				    <c:if test="${!empty queslist.pdlist}">
				       <c:forEach items="${queslist.pdlist }" var="ques" varStatus="ss">
				        <tr>
				             <td colspan='2'>
				              <span class="problems">${ss.count}.&nbsp;${ques.problem }</span>&nbsp;
				              </td></tr>
				        <tr><td class="xuanxiang" colspan='2'><input type='radio' name='${ques.id }' value="1">正确&nbsp;&nbsp;<input type='radio' name='${ques.id }' value="0">错误</td></tr>
					   </c:forEach>
				     </c:if>
				      <tr><td colspan="2"></td></tr>
				    <tr><td style="height:25px;" colspan="2">四、简答题（5*8分）</td></tr>
				     <c:if test="${!empty queslist.jdlist}">
				       <c:forEach items="${queslist.jdlist }" var="ques" varStatus="ss">
				        <tr>
				             <td colspan='2'>
				              <span class="problems">${ss.count}.&nbsp;${ques.problem }</span>&nbsp;
				              </td></tr>
				        <tr><td class="xuanxiang" colspan='2'><textarea class='jdans' id='jd_${ques.id }' onkeyup='this.value = this.value.substring(0, 500);'></textarea></td></tr>
					   </c:forEach>
				     </c:if>
				    <tr><td colspan="2"></td></tr>
			       </table>
			       <c:if test="${empty score}">
			        <img onclick="JiaoJuan()" style="border:0px;margin-bottom:20px;cursor:pointer;" src="img/qt/jiaojuan.jpg"/>
			       </c:if>
			      <c:if test="${!empty score}">
			        <a href="nmks.do">
			          <img style="border:0px;margin-bottom:20px;" src="img/qt/jiaojuan.jpg"/>这里重新考试的按钮
			        </a>
			       </c:if>
			    </c:if>
			     <c:if test="${empty queslist}">
			                     问题数量不足！
			     </c:if>
			     
           </div>
           <div id="mainbottom"></div>
       </div>
      <div id="footht" style=""></div>
      <div id="footer">
		  <jsp:include page="footer.jsp" flush="true"></jsp:include>
	   </div>
     </div>
     <div id="mainright"><img src="img/qt/mainright.jpg" style="width:100%;height:100%;"/></div>
     <form id="jiaojuansum" name="jiaojuansum" method="post" action="goexam.do" >
       <input id="eid" name="eid" type="hidden" value="${exam.id}">
       <input id="xzds" name="xzds" type="hidden" value="">
       <input id="tkds" name="tkds" type="hidden" value="">
       <input id="pdds" name="pdds" type="hidden" value="">
       <input id="jdds" name="jdds" type="hidden" value="">
     </form>
  </body>
<SCRIPT LANGUAGE="JavaScript">   
		<!--   
	     //下面兼容ie6
	     var isIE = !!window.ActiveXObject;  
		 var isIE6 = isIE && !window.XMLHttpRequest; 
		 if (isIE6) {  
	      $("#timeleng").css("margin-left","217px");
	      $("#nowlist").css("margin-left","5px");
	    } 
		//-->   
</SCRIPT>
</html>
